/*
 * Copyright 2007 - The JDPF Project Team (http://www.jdpf.org) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.jdpf.core.kernel.elements;


/**
 * An abstract net element.
 * 
 * @author Paolo Ciccarese
 */
public class AbstractNetElement {
	
	private static final String ANONYMOUS = "ANONYMOUS";
	
	/**
	 * The unique and immutable net element identifier.
	 */
	private String id;
	/**
	 * The immutable net element name.
	 */
	private String name;
	
	/**
	 * Full net element constructor.
	 * @param id	The unique identifier of the net element
	 * @param name	The human readable name of the net element
	 */
	public AbstractNetElement(final String id, final String name) {
		super();
		this.id = id;
		this.name = name;
	}

	/**
	 * Partial net element constructor, the name is generated automatically.
	 * @param name	The human readable name of the net element
	 */
	public AbstractNetElement(final String id) {
		super();
		this.id = id;
		this.name = ANONYMOUS + "_" + id;
	}
	
	/* (non-Javadoc)
	 * @see org.jdpf.core.model.INetElement#getName()
	 */
	public String getName() {
		return name;
	}

	/* (non-Javadoc)
	 * @see org.jdpf.core.model.INetElement#getId()
	 */
	public String getId() {
		return id;
	}
	
	public void setId(final String id){
		this.id=id;
	}
	
	public void setName(final String name){
		this.name=name;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		StringBuilder sb = new StringBuilder();
//		sb.append(" - ");
		sb.append(id);
		sb.append(" - ");
		sb.append(name);
		return sb.toString();
	}
	
//	public String toString() {
//		StringBuilder sb = new StringBuilder();
//		sb.append("Id: ");
//		sb.append(id);
//		sb.append("\nName: ");
//		sb.append(name);
//		return sb.toString();
//	}
}
